[jQuery] How do I invoke custom plugin on click?

Posted by Steven on Stack Overflow See other posts from Stack Overflow or by Steven
Published on 2010-06-11T14:52:59Z Indexed on 2010/06/11 15:02 UTC
Read the original article Hit count: 145

Filed under:

I have the following code:

(function(jQuery){
  jQuery.fn.timepicker = function(){
      return this.each(function(){
        jQuery(this).val("14:00");   
    });
    };
})(jQuery);

Currently I invoke this function by the following code: $("#event_start_time").timepicker();

Where #event_start_time is the ID of an <input> field.

How can I invoke this code only when I click inside the text box?

© Stack Overflow or respective owner

Related posts about jquery-plugins